{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Employee:\n",
    "    '所有员工的基类'\n",
    "    empCount = 0\n",
    "    def __init__(self,name,salary):\n",
    "        self.name = name\n",
    "        self.salary = salary\n",
    "        Employee.empCount += 1\n",
    "        \n",
    "    def desplayCount(self):\n",
    "        print 'Total Employee %d' % Employee.empCount\n",
    "    \n",
    "    def desplayEmployee(self):\n",
    "        print \"Name : \",self.name,\", Salary : \",self.salary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<__main__.Test instance at 0x0000000004EABF48>\n",
      "__main__.Test\n"
     ]
    }
   ],
   "source": [
    "class Test:\n",
    "    def prt(self):\n",
    "        print self\n",
    "        print self.__class__\n",
    "        \n",
    "t = Test()\n",
    "t.prt()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<__main__.Test instance at 0x0000000004EC80C8>\n",
      "__main__.Test\n"
     ]
    }
   ],
   "source": [
    "class Test:\n",
    "    def prt(ch):\n",
    "        print ch\n",
    "        print ch.__class__\n",
    "        \n",
    "t = Test()\n",
    "t.prt()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Name :  Sara , Salary :  2000\n",
      "Name :  Tony , Salary :  8000\n",
      "Total Employee 2\n",
      "False\n",
      "True\n",
      "8\n",
      "28\n",
      "False\n",
      "Employee.__doc__: 所有员工的基类\n",
      "Employee.__name__: Employee\n",
      "Employee.__module__ __main__\n",
      "Employee.__bases__ ()\n",
      "Employee.__dic__ {'__module__': '__main__', 'desplayCount': <function desplayCount at 0x0000000004FF2BA8>, 'empCount': 2, '__doc__': '\\xe6\\x89\\x80\\xe6\\x9c\\x89\\xe5\\x91\\x98\\xe5\\xb7\\xa5\\xe7\\x9a\\x84\\xe5\\x9f\\xba\\xe7\\xb1\\xbb', 'desplayEmployee': <function desplayEmployee at 0x0000000004FF22E8>, '__init__': <function __init__ at 0x0000000004FF2438>}\n"
     ]
    }
   ],
   "source": [
    "class Employee:\n",
    "    '所有员工的基类'\n",
    "    empCount = 0\n",
    "    def __init__(self,name,salary):\n",
    "        self.name = name\n",
    "        self.salary = salary\n",
    "        Employee.empCount += 1\n",
    "        \n",
    "    def desplayCount(self):\n",
    "        print 'Total Employee %d' % Employee.empCount\n",
    "    \n",
    "    def desplayEmployee(self):\n",
    "        print \"Name : \",self.name,\", Salary : \",self.salary\n",
    "\n",
    "emp1 = Employee('Sara',2000)\n",
    "emp2 = Employee('Tony',8000)\n",
    "\n",
    "emp1.desplayEmployee()\n",
    "emp2.desplayEmployee()\n",
    "\n",
    "print 'Total Employee %d' % Employee.empCount"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Name :  Sara , Salary :  2000\n",
      "Name :  Tony , Salary :  8000\n",
      "Total Employee 2\n",
      "False\n",
      "True\n",
      "8\n",
      "28\n",
      "False\n",
      "Employee.__doc__: 所有员工的基类\n",
      "Employee.__name__: Employee\n",
      "Employee.__module__ __main__\n",
      "Employee.__bases__ ()\n",
      "Employee.__dic__ {'__module__': '__main__', 'desplayCount': <function desplayCount at 0x0000000004FF2C18>, 'empCount': 2, '__doc__': '\\xe6\\x89\\x80\\xe6\\x9c\\x89\\xe5\\x91\\x98\\xe5\\xb7\\xa5\\xe7\\x9a\\x84\\xe5\\x9f\\xba\\xe7\\xb1\\xbb', 'desplayEmployee': <function desplayEmployee at 0x0000000004FF2208>, '__init__': <function __init__ at 0x0000000004FF2A58>}\n"
     ]
    }
   ],
   "source": [
    "class Employee:\n",
    "    '所有员工的基类'\n",
    "    empCount = 0\n",
    "    def __init__(self,name,salary):\n",
    "        self.name = name\n",
    "        self.salary = salary\n",
    "        Employee.empCount += 1\n",
    "        \n",
    "    def desplayCount(self):\n",
    "        print 'Total Employee %d' % Employee.empCount\n",
    "    \n",
    "    def desplayEmployee(self):\n",
    "        print \"Name : \",self.name,\", Salary : \",self.salary\n",
    "\n",
    "emp1 = Employee('Sara',2000)\n",
    "emp2 = Employee('Tony',8000)\n",
    "\n",
    "emp1.desplayEmployee()\n",
    "emp2.desplayEmployee()\n",
    "\n",
    "print 'Total Employee %d' % Employee.empCount\n",
    "\n",
    "\n",
    "emp1.age = 7\n",
    "emp2.age = 8\n",
    "\n",
    "del emp1.age\n",
    "\n",
    "print hasattr(emp1,'age')\n",
    "print hasattr(emp2,'age')\n",
    "print getattr(emp2,'age')\n",
    "setattr(emp1,'age',28)\n",
    "print getattr(emp1,'age')\n",
    "delattr(emp1,'age')\n",
    "print hasattr(emp1,'age')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Employee.__doc__: 所有员工的基类\n",
      "Employee.__name__: Employee\n",
      "Employee.__module__ __main__\n",
      "Employee.__bases__ ()\n",
      "Employee.__dic__ {'__module__': '__main__', 'desplayCount': <function desplayCount at 0x0000000004FF2C88>, 'empCount': 0, '__doc__': '\\xe6\\x89\\x80\\xe6\\x9c\\x89\\xe5\\x91\\x98\\xe5\\xb7\\xa5\\xe7\\x9a\\x84\\xe5\\x9f\\xba\\xe7\\xb1\\xbb', 'desplayEmployee': <function desplayEmployee at 0x0000000004FF2438>, '__init__': <function __init__ at 0x0000000004FF2668>}\n"
     ]
    }
   ],
   "source": [
    "class Employee:\n",
    "    '所有员工的基类'\n",
    "    empCount = 0\n",
    "    def __init__(self,name,salary):\n",
    "        self.name = name\n",
    "        self.salary = salary\n",
    "        Employee.empCount += 1\n",
    "        \n",
    "    def desplayCount(self):\n",
    "        print 'Total Employee %d' % Employee.empCount\n",
    "    \n",
    "    def desplayEmployee(self):\n",
    "        print \"Name : \",self.name,\", Salary : \",self.salary\n",
    "\n",
    "print 'Employee.__doc__:',Employee.__doc__\n",
    "print 'Employee.__name__:',Employee.__name__\n",
    "print 'Employee.__module__',Employee.__module__\n",
    "print 'Employee.__bases__',Employee.__bases__\n",
    "print 'Employee.__dic__',Employee.__dict__"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.15"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
